cPy.cRender module

Contents

cPy.cRender module#

Expand for references to cPy.cRender

class image_format(value)[source]#

Bases: Enum

The coat namespace used for most 3DCoat API calls except low-level internal structures.
fmtNone = 0#
R8 = 1#
Rg8 = 2#
Rgb8 = 3#
Rgba8 = 4#
R16 = 5#
Rg16 = 6#
Rgb16 = 7#
Rgba16 = 8#
R16f = 9#
Rg16f = 10#
Rgb16f = 11#
Rgba16f = 12#
R32f = 13#
Rg32f = 14#
Rgb32f = 15#
Rgba32f = 16#
Depth16 = 17#
Depth24 = 18#
Depth24Stencil8 = 19#
Dxt1 = 20#
Dxt3 = 21#
Dxt5 = 22#
PVRTC4 = 23#
PVRTC4_Alpha = 24#
Count = 25#
class RenderUtils[source]#

Bases: object

Base class for rendering utilities
static CreateFBO(width: int, height: int, format: image_format) int[source]#
Create frame buffer object. An FBO is a texture or data that can accept a rendered result
Parameters:
  • width (int) – The size of the sampler in width

  • height (int) – The size of the sampler in height

  • format (image_format) – image_format - enum with the number of channels and the channel type. For example coat.image_format.Rgb8

Returns:

texture id - can be used as texture id and as FBO for rendering target

Return type:

int

static clear(fbo_id: int, fill_color: any, clear_color: bool = True, clear_depth: bool = True, fill_depth: float = 1) int[source]#
Clear the framebuffer object - fill each pixel of the FBO sample with the same data
Parameters:
  • fbo_id (int) – FBO ID to be filled for clearing

  • fill_color – Color to fill each pixel

  • clear_color (bool) – Do you want to clear the FBO color? if “true” the color of each pixel will be changed to fill_color, if “false” the color will not be changed.

  • clear_depth (bool) – Do you want to clear the FBO depth? if “true” the depth of each pixel will be changed to fill_depth, if “false” the depth will not be changed.

  • fill_depth (float) – Depth value for fill each pixel

Returns:

true if successfully

Return type:

int

static draw_on_screen(texture: int = 1, left: int = 0, top: int = 0, right: int = 0, bottom: int = 0, red: int = 255, green: int = 255, blue: int = 255, opacity: int = 255) int[source]#
Draw a texture rectangle in the main 3DCoat window
Parameters:
  • texture (int) – The ID of the texture that will be rendered

  • left (int) – The position of the left side of the rendered texture on the screen

  • top (int) – The position of the top side of the rendered texture on the screen

  • right (int) – The position of the right side of the rendered texture on the screen

  • bottom (int) – The position of the bottom side of the rendered texture on the screen

  • red (int) – Multiplier for the red channel of the texture

  • green (int) – Multiplier for the green channel of the texture

  • blue (int) – Multiplier for the blue channel of the texture

Returns:

true if successfully

Return type:

int

static draw_text(x: float, y: float, text: str, color_r: float = 1, color_g: float = 1, color_b: float = 1, color_a: float = 1) int[source]#
Draw the text in the main 3DCoat window
Parameters:
  • x (float) – The position of the left side of the text block

  • y (float) – The position of the top side of the text block

  • text (str) – The content of the text block you want to display

  • color_r (float) – Value of the red channel of the text color

  • color_g (float) – Value of the gleen channel of the text color

  • color_b (float) – Value of the blue channel of the text color

  • color_a (float) – Opacity of the rendered text

Returns:

true if successfully

Return type:

int

static CreateGPUTexture(src_data: any, format: image_format) int[source]#
Create a 2D sampler in GPU memory from a numpy array
Parameters:
  • src_data – numpy array from which the 2d sampler will be created. A numpy array must have the correct width and height, type and number of channels as in OpenCV

  • format (image_format) – The texture type must match the numpy structure and type. For example coat.image_format.Rgb8

Returns:

the texture id of the new sampler

Return type:

int

static GPUTextureFromFile(file_path: str, Clamp: bool = False, Smooth: bool = True, swapRB: bool = False, Flip: bool = False) int[source]#
Create a 2D sampler in GPU memory from a numpy array
Returns:

the texture id of the new sampler

Return type:

int

static DeleteGPUTexture(texture_id: int) bool[source]#
Remove sampler from GPU memory
Parameters:

texture_id (int) – Texture ID

Returns:

true if successfully

Return type:

bool

static work_area() any[source]#
3DCoat workspace rectangle (viewport)
static GetTextureID(Name: str, Clamp: bool = False, Smooth: bool = False, swapRB: bool = False, Flip: bool = False) int[source]#
static GetTextureName(TextureID: int) str[source]#
static GetTextureWidth(TextureID: int) int[source]#
static GetTextureHeight(TextureID: int) int[source]#
static GetShaderID(Name: str, VType: int, Extra: str = None) int[source]#
static GetScreenShader(name: str) int[source]#
static GetWorldShader(name: str) int[source]#
static SetShader(ShaderID: int)[source]#
static GetShader() int[source]#
static SetShaderVar(Shader: int, Var: int, m: cMat4)[source]#
static GetViewPort() any[source]#
static SetViewPort(R: any)[source]#
static AddRenderTargetRGBA(width: int, Height: int, Linear: bool = True) int[source]#
static PushRenderTarget(Target: int)[source]#
static PopRenderTarget()[source]#
static ClearDevice()[source]#
static GetTexMemorySize() int[source]#
static GetWorldViewProjTM() cMat4[source]#
static GetWorldViewProjTMInv() cMat4[source]#
static SetWorldViewProjTM(M: cMat4)[source]#
static GetHWND() any[source]#
static GetHomeDirectory() str[source]#
static PickPointPos() cVec3[source]#
static PickPointSpacePos() cVec3[source]#
static GetPickRay(V: cVec2) cVec3[source]#
static GetPickRayFrom(V: cVec2) cVec3[source]#
static GetPickRayWVPTM(V: cVec2) cVec3[source]#
static GetPickRayWVPTMFrom(V: cVec2) cVec3[source]#
static Flush()[source]#
static drawPicture(rect: any, Texture: int, Color: int, Shadow: bool)[source]#
static drawBottomAlignedText(xb: int, yb: int, Text: str, MaxLx: int, FontSize: int, Color: int, Align: int, Draw: bool) int[source]#
static drawCenetrAlignedText(x: int, y: int, Text: str, MaxLx: int, FontSize: int, Color: int) int[source]#
static drawMultilineText(x: int, y: int, s: str, DefaultFont: int, DefColor: int, MaxLx: int, MaxLy: int = 100000, CenterX: any = 0, Draw: bool = True) int[source]#
static drawThickLine(V1: cVec3, V2: cVec3, Color1: int, Color2: int, Thickness: float)[source]#
static drawThickCurve(curve: list[cVec2], Color: int, Thickness: float)[source]#
static drawThickCircle(pos: cVec3, n: cVec3, R: float, Color: int, Thickness: float)[source]#
static drawCoolSphere(Center: cVec3, R: float, Color: int, Dense: bool = False)[source]#
static drawCoolScreenSphere(Center: cVec3, R: float, Color: int)[source]#
static drawThickArrow(x: float, y: float, x1: float, y1: float, Color1: int, Color2: int, Thickness: float)[source]#
static drawScreenArrow(Start: cVec3, End: cVec3, Size: float, Color: int)[source]#
static drawTransformedText(x: float, y: float, text: str, Color: int, shadow: bool = False, Angle: float = 0.0, Scale: float = 1.0, HorizontalShift: float = 0.0, VerticalShift: float = 1.0)[source]#
static screenToWorldSpace(v: cVec3) cVec3[source]#
static screenToWorldSpaceZ(v: cVec3) cVec3[source]#
static worldToScreenSpace(v: cVec3) cVec3[source]#
static worldToScreenSpaceZ(v: cVec3) cVec3[source]#